﻿using System;
using System.Collections.Generic;
using Microsoft.SharePoint.Administration;

namespace SP.FeatureAdministrationTool.Extensions
{
    public static class SPFarmExtension
    {
        public static List<SPWebApplication> GetAllWebApplications(this SPFarm farm)
        {
            if (farm == null)
            {
                throw new ArgumentNullException("farm");
            }

            List<SPWebApplication> allApps = new List<SPWebApplication>();
            foreach (SPWebApplication webApp in SPWebService.AdministrationService.WebApplications)
            {
                allApps.Add(webApp);
            }

            foreach (SPWebApplication webApp in SPWebService.ContentService.WebApplications)
            {
                allApps.Add(webApp);
            }

            return allApps;
        }
    }
}
